﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using CRM.UTIL;
using System.Data.SqlClient;

namespace CRM.DAL.Role
{
    public class OrderInfoD : DBChannel
    {

        #region 执行存储过程 Pro_GetOrderInfo ,根据条件获取回馈信息
        /// <summary>
        /// 执行存储过程 Pro_GetOrderInfo 
        ///向国祥
        /// </summary>

        public DataTable ExecuteGetOrderInfo(ref CRM.MODEL.GetOrderInfo stu)
        {
            //存储过程参数	 		     
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.ORDERNO_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.GUARANTEENO_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.BUYERID_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.BUYERFULLNAME_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.BUYERADD_PARM, SqlDbType.NVarChar, 1000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.BUYERTEL_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.ORDERDATE_PARM, SqlDbType.DateTime));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.DELIVERYDATE_PARM, SqlDbType.DateTime));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.PRODUCTTITLE_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.PRODUCTMODEL_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.PRODUCTBRAND_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.PRODUCTCOLOR_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.RAM_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.ROM_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.NETWORK4G_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.BAND4G_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.NETWORK3G_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.BAND3G_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.NETWORK2G_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.BAND2G_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.ISDEL_PARM, SqlDbType.Char, 1));

            //分页参数
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.ORDERSTRING_PARM, SqlDbType.VarChar, 1000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.PAGESIZE_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.CURRENTPAGEINDEX_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetOrderInfo.TOTALITEMS_PARM, SqlDbType.Decimal));

            //设置参数的值
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.ORDERNO_PARM].Value = stu.ORDERNO_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.GUARANTEENO_PARM].Value = stu.GUARANTEENO_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.BUYERID_PARM].Value = stu.BUYERID_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.BUYERFULLNAME_PARM].Value = stu.BUYERFULLNAME_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.BUYERADD_PARM].Value = stu.BUYERADD_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.BUYERTEL_PARM].Value = stu.BUYERTEL_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.ORDERDATE_PARM].Value = stu.ORDERDATE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.DELIVERYDATE_PARM].Value = stu.DELIVERYDATE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.PRODUCTTITLE_PARM].Value = stu.PRODUCTTITLE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.PRODUCTMODEL_PARM].Value = stu.PRODUCTMODEL_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.PRODUCTBRAND_PARM].Value = stu.PRODUCTBRAND_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.PRODUCTCOLOR_PARM].Value = stu.PRODUCTCOLOR_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.RAM_PARM].Value = stu.RAM_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.ROM_PARM].Value = stu.ROM_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.NETWORK4G_PARM].Value = stu.NETWORK4G_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.BAND4G_PARM].Value = stu.BAND4G_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.NETWORK3G_PARM].Value = stu.NETWORK3G_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.BAND3G_PARM].Value = stu.BAND3G_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.NETWORK2G_PARM].Value = stu.NETWORK2G_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.BAND2G_PARM].Value = stu.BAND2G_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.ISDEL_PARM].Value = stu.ISDEL_VALUE;

            //设置分页参数的值
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.ORDERSTRING_PARM].Value = stu.ORDERSTRING_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.PAGESIZE_PARM].Value = stu.PAGESIZE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.CURRENTPAGEINDEX_PARM].Value = stu.CURRENTPAGEINDEX_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.TOTALITEMS_PARM].Value = stu.TOTALITEMS_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.TOTALITEMS_PARM].Direction = ParameterDirection.Output;

            //执行
            DataTable dt = this.GetDataByProcedure("dbo.Pro_GetOrderInfo");
            //获取数据库的信息
            stu.TOTALITEMS_VALUE = this.sqlCmd.Parameters[CRM.MODEL.GetOrderInfo.TOTALITEMS_PARM].Value;

            return dt;
        }
        #endregion







        #region 执行存储过程 Pro_EditOrderInfo,根据条件获取回馈信息
        /// <summary>
        /// 执行存储过程 Pro_EditOrderInfo 的相关参数
        ///向国祥
        /// </summary>

        public int ExecuteEditOrderInfo(ref CRM.MODEL.EditOrderInfo stu)
        {
            //动作参数
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.ACTION_PARM, SqlDbType.VarChar, 20));
            //错误信息参数
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.ERRMSG_PARM, SqlDbType.VarChar, 100));
            ////表字段参数
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.ORDERNO_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.GUARANTEENO_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.BUYERID_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.BUYERFULLNAME_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.BUYERADD_PARM, SqlDbType.NVarChar, 1000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.BUYERTEL_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.ORDERDATE_PARM, SqlDbType.DateTime));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.DELIVERYDATE_PARM, SqlDbType.DateTime));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.PRODUCTTITLE_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.PRODUCTMODEL_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.PRODUCTBRAND_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.PRODUCTCOLOR_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.RAM_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.ROM_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.NETWORK4G_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.BAND4G_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.NETWORK3G_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.BAND3G_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.NETWORK2G_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.BAND2G_PARM, SqlDbType.NVarChar, 200));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditOrderInfo.ISDEL_PARM, SqlDbType.Char, 1));



            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.ACTION_PARM].Value = stu.ACTION_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.ERRMSG_PARM].Direction = ParameterDirection.Output;
            //设置参数的值
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.ORDERNO_PARM].Value = stu.ORDERNO_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.GUARANTEENO_PARM].Value = stu.GUARANTEENO_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.BUYERID_PARM].Value = stu.BUYERID_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.BUYERFULLNAME_PARM].Value = stu.BUYERFULLNAME_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.BUYERADD_PARM].Value = stu.BUYERADD_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.BUYERTEL_PARM].Value = stu.BUYERTEL_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.ORDERDATE_PARM].Value = stu.ORDERDATE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.DELIVERYDATE_PARM].Value = stu.DELIVERYDATE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.PRODUCTTITLE_PARM].Value = stu.PRODUCTTITLE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.PRODUCTMODEL_PARM].Value = stu.PRODUCTMODEL_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.PRODUCTBRAND_PARM].Value = stu.PRODUCTBRAND_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.PRODUCTCOLOR_PARM].Value = stu.PRODUCTCOLOR_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.RAM_PARM].Value = stu.RAM_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.ROM_PARM].Value = stu.ROM_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.NETWORK4G_PARM].Value = stu.NETWORK4G_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.BAND4G_PARM].Value = stu.BAND4G_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.NETWORK3G_PARM].Value = stu.NETWORK3G_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.BAND3G_PARM].Value = stu.BAND3G_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.NETWORK2G_PARM].Value = stu.NETWORK2G_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.BAND2G_PARM].Value = stu.BAND2G_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.ISDEL_PARM].Value = stu.ISDEL_VALUE;

            int i = this.ExecuteProcedure("dbo.Pro_EditOrderInfo");//执行	
            //获取数据库的信息
            stu.ERRMSG_VALUE = this.sqlCmd.Parameters[CRM.MODEL.EditOrderInfo.ERRMSG_PARM].Value;
            return i;
        }
        #endregion
    }

}
